package com.bj58.wf.training.first.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bj58.wf.mvc.ActionResult;
import com.bj58.wf.mvc.MvcController;
import com.bj58.wf.mvc.BeatContext.Model;
import com.bj58.wf.mvc.annotation.GET;
import com.bj58.wf.mvc.annotation.POST;
import com.bj58.wf.mvc.annotation.Path;
import com.bj58.wf.training.first.interceptors.Crazy;



/**
 * 这是一个演示类，用于演示MVC的基本功能
 * @author renjun
 *
 */
@Path("/usercenter")
@Crazy
public class HelloController extends MvcController{
	
	
	@Path("/")
	@GET
	@POST
	public ActionResult userCenter() {
		String view = "home";
		System.err.println(beat.getServer().getContextPath());
		return ActionResult.view(view);

	}
	
	@Path("/home")
	@GET
	@Crazy
	public ActionResult home() {
		String view = "home";
		System.err.println(beat.getServer().getContextPath());
		return ActionResult.view(view);
	}
	@Path("/crazy")
	@GET
	public ActionResult hello(){
		String hello = "crazy";
		System.out.println(hello);
		return ActionResult.view(hello);
	}
	
	@Path("hello/{username}")
	public ActionResult helloU(String username){
		HttpServletRequest request = beat.getRequest();
		HttpServletResponse response = beat.getResponse();
		Model model= beat.getModel();
		
		boolean isUpload = beat.getClient().isUpload();
		
		beat.getModel().add("username", username);
		return ActionResult.view("hello");
	}
}
